﻿using System;
using System.Collections.Generic;
using System.Linq;
using Entropy.Ext.Ast;

namespace Entropy.Ext
{
	public static class NodeExtensions
	{
		public static void ForEach<T>(this IEnumerable<T> source, Action<T> action) where T: Node
		{
			if (source != null)
				foreach (var item in source)
					action(item);
		}

		public static IEnumerable<T> OfType<T>(this IEnumerable<Node> source) 
		{
			return source.Where(n => n is T).Cast<T>().ToList();
		}
	}
}